Skip to content

Blocks: Include block name context in WP_Block_Type_Registry::registe…#11478

Open
manishdhorepatil-art wants to merge 3 commits intoWordPress:trunkfrom
manishdhorepatil-art:ticket-65039
Open

Blocks: Include block name context in WP_Block_Type_Registry::registe…#11478
manishdhorepatil-art wants to merge 3 commits intoWordPress:trunkfrom
manishdhorepatil-art:ticket-65039

Conversation

@manishdhorepatil-art
Copy link
Copy Markdown

@manishdhorepatil-art manishdhorepatil-art commented Apr 9, 2026

Tested the existing patch and it works as expected.

Testing Instructions:

  1. Apply the patch from PR Include block name context in _doing_it_wrong messages in WP_Block_Type_Registry::register() #11475.

  2. In a test plugin or theme, try registering a block with an invalid name (e.g., containing uppercase characters):

    register_block_type( 'MyBlock' );

  3. Observe the _doing_it_wrong() notice.

Results:

  • Before applying the patch:
    The error message is generic and does not indicate which block caused the issue.

    Example:
    "Block type names must not contain uppercase characters."

  • After applying the patch:
    The error message correctly includes the block name, making debugging easier.

    Example:
    "Block type "MyBlock" must not contain uppercase characters."

  1. Also verified similar improvements for other _doing_it_wrong() calls in WP_Block_Type_Registry::register().

Ticket track - https://core.trac.wordpress.org/ticket/65039

Testing the patch

  1. I tested this issue by creating a sample plugin that registers invalid block types:
    https://www.dropbox.com/scl/fi/yydrbuv2saaf8w7gmw4yy/test-invalid-block.zip?rlkey=f1u85jp0424lqczpvtltve6j1&st=h30rmcia&dl=0

The plugin includes the following invalid cases:

  • Block names with uppercase characters
  • Missing namespace
  • Invalid characters
  1. I enabled WP_DEBUG and verified the output in the debug.log file:
    https://github.com/user-attachments/files/26590078/debug.log

Result:
The _doing_it_wrong() messages now correctly include the block name causing the issue, improving debugging clarity.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @ManishDhorepatil.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props manishxdp, westonruter, desrosj.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@manishdhorepatil-art
Copy link
Copy Markdown
Author

  1. I tested this issue by creating a sample plugin that registers invalid block types:
    https://www.dropbox.com/scl/fi/yydrbuv2saaf8w7gmw4yy/test-invalid-block.zip?rlkey=f1u85jp0424lqczpvtltve6j1&st=h30rmcia&dl=0

The plugin includes the following invalid cases:

  • Block names with uppercase characters
  • Missing namespace
  • Invalid characters
  1. I enabled WP_DEBUG and verified the output in the debug.log file:
    https://github.com/user-attachments/files/26590078/debug.log

Result:
The _doing_it_wrong() messages now correctly include the block name causing the issue, improving debugging clarity.

@westonruter westonruter requested a review from Copilot April 9, 2026 09:41
Copy link
Copy Markdown
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves _doing_it_wrong() notices emitted by WP_Block_Type_Registry::register() by adding more context about invalid block type inputs, making debugging easier.

Changes:

  • Include the received type when a non-string block name is passed.
  • Include the invalid block name in notices for uppercase characters and missing namespace prefix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wp-includes/class-wp-block-type-registry.php Outdated
Comment thread src/wp-includes/class-wp-block-type-registry.php Outdated
Comment thread src/wp-includes/class-wp-block-type-registry.php Outdated
Comment thread src/wp-includes/class-wp-block-type-registry.php Outdated
manishdhorepatil-art and others added 2 commits April 9, 2026 23:16
Co-authored-by: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com>
Co-authored-by: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com>
@manishdhorepatil-art
Copy link
Copy Markdown
Author

@desrosj done changes

@manishdhorepatil-art
Copy link
Copy Markdown
Author

@desrosj changes done can you please review once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants